package com.g2room.java8;

import java.util.Collection;
import java.util.stream.Collectors;

/**
 * 基础示例：字符串、数值、算术和文件
 */
public class BaseSample {

    /**
     * 字符串新增了两个新方法：join和chars
     */
    public static void stringSample() {
        System.out.println("********************* String *********************");
        // join，字符串拼接
        String newStr = String.join(",", "张三", "李四", "王五", "赵六");
        System.out.println("after join = " + newStr);
        // 转换为字符后，可以采用流式操作
        String str1 = newStr.chars().distinct().sorted().collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString();
        System.out.println("str1 = " + str1);
    }

}
